<!DOCTYPE html>
<html>
	<head>
	    <meta charset="utf-8">
	    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
	    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
	    <title>Hello APP</title>
	    <link rel="stylesheet" type="text/css" href="../../css/index.css" />
	</head>
	<style type="text/css">
		.warp{width: 100%;}

		.info-box{width: 100%;box-sizing: border-box;}
		.info-box .info-one{align-items: center;height: 50px;padding: 0 15px;background: #FFFFFF;margin-bottom: 10px;box-sizing: border-box;}
		.info-box .info-one input{text-align: right;padding: 10px 0;line-height: 30px;box-sizing: border-box;}
		.info-box .info-one.goto{background: url(../../image/main3/main3_goto.png) no-repeat right 10px center #FFFFFF;background-size:14px;padding-right: 30px;}
		.info-box .liuyan-box{padding:15px;background: #FFFFFF;margin-bottom: 10px;box-sizing: border-box;}
		.info-box .liuyan-box textarea{width: 100%;height: 190px;font-size: 14px;}
		.info-box .liuyan-box .num{text-align: right;font-size: 12px;color: #666666;}
		.shouhuo-btn{height: 45px;background:#FF9502;height: 45px;border-radius:4px;text-align: center;line-height: 45px;font-size: 18px;color: #FFFFFF;margin: 60px 15px 30px 15px;}

	</style>
	<body>
		<div id="vue" class="warp">

			<div class="info-box">
	        	<div class="info-one flex goto" tapmode onclick="sel_type()">
	        		<div class="text">反馈类型</div>
	        		<input class="flex1" type="text" disabled="false" disabled="false" id="fankuitype" placeholder=""/>
	        	</div>
	        	<div class="liuyan-box">
	        		<textarea maxlength="300" id="miaoshu" oninput="inputMiaoShu(this)" placeholder="描述您的建议"></textarea>
	        		<div class="num" id="numLength">0/300</div>
	        	</div>
	        	<div class="info-one flex">
	        		<div class="text">联系方式</div>
	        		<input class="flex1" type="tel" maxlength="11" id="phone" placeholder="留下联系方式，方便我们与您联系"/>
	        	</div>
			</div>
			<div class="shouhuo-btn" tapmode onclick="upData()">提交</div>

		</div>
	</body>
</html>
<script type="text/javascript" src="../../script/base.min.js" id="loadjs" data-js="L/swiper.min,L/lazyload,L/h-tool"></script>
<script type="text/javascript">

	define(function (require, exports, module) {

		var system = lanYun.getStorage("system");
		var typeData = [];
		if(system){
			$.each( system.fankuiType , function(i, n){
				var item = {};
				item.type = i ;
				item.name = n ;
				typeData.push(item);
			});
		}

		// 提交更换的手机信息
		upData = function (){
			var data = {};
			data.type = $('#fankuitype').val();
			data.content = $('#miaoshu').val();
			data.phone = $('#phone').val();
			if(!data.phone) {
	            lanYun.toast('请填写联系方式');
	            return;
	        }
	        if(!TOOL.check.isMobile(data.phone)) {
	            lanYun.toast('请填写正确联系方式');
	            return;
	        }
			if(!data.type) {
				lanYun.toast('请选择反馈类型');
				return;
			}
			if(!data.content) {
				lanYun.toast('请输入问题描述');
				return;
			}
			//console.log(JSON.stringify(data));
			lanYun.post('fankui/index', data ,function (ret) {
				//console.log(JSON.stringify(ret));
				if(ret.errcode == 0){
					lanYun.alert({fname:'diaLogBox1',title:'提示', button:['确定'],content: '您已反馈成功！'},function(ret){
						api.closeWin()
			        });
				}else {
					lanYun.toast(ret.msg);
				}
			},2);
		}

		//选择反馈类型
		sel_type = function(){
			if(typeData.length <= 0){
				lanYun.toast('参数错误');
				return;
			}
			//console.log(JSON.stringify(typeData));
			lanYun.actionSelect({
				col:1,
				data:typeData,
				title:'反馈类型',
				successCall:function(result){
					if(result && result.eventType == 'ok' && result.selectedInfo){
						var result_data = result.selectedInfo[0];
						$('#fankuitype').val(result_data.name);
					}
				}
			});
		};

		// 输入长度
		inputMiaoShu = function (tis){
			var length = $(tis).val().length;
			$('#numLength').html(length + '/300');
		}

	});

</script>
